package com.superman.supermarket.client.activity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.Window;
import com.google.inject.Inject;
import com.superman.mvpframe.client.ajax.PostManAsyncCallBack;
import com.superman.mvpframe.client.mvp.IPageView;
import com.superman.mvpframe.client.mvp.IPageViewPresenter;
import com.superman.mvpframe.client.utils.StringUtils;
import com.superman.mvpframe.client.utils.XJsonUtil;
import com.superman.mvpframe.client.widget.mescroll.UpAndDownCallBack;
import com.superman.supermarket.client.mvp.ShopAbstractActivity;
import com.superman.supermarket.client.view.skulist.SkuListView;

/**
 * 专区商品列表
 * 
 * @author superman
 * @version 2018年8月2日下午5:08:48
 */
public class SpecialSkuListActivity extends ShopAbstractActivity implements UpAndDownCallBack {

	private String sid;

	@Inject
	SkuListView skuListView;

	@Override
	public void getListDataByPage(int page) {

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("SPECIAL_ID", sid);
		map.put("PAGE_INDEX", page);

		postman.post("/special/querySkus", map, new PostManAsyncCallBack() {

			@Override
			public void onBusinessError(String statusCode) {

			}

			@Override
			public void onBusinessOK(String response) {
				List<Map<String, Object>> list = XJsonUtil.getList(response);
				skuListView.getPullToRefreshView().endBySize(list, XJsonUtil.getCount(response));
			}
		});

	}

	@Override
	public IPageView getView() {
		return skuListView;
	}

	@Override
	public IPageViewPresenter getViewPresenter() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onActivity(EventBus eventBus) {
	}

	@Override
	public void popToRefresh() {
		// TODO Auto-generated method stub
	}

	@Override
	public void popToRefresh(Object contextData) {
		// TODO Auto-generated method stub

	}

	@Override
	public void pushToRefresh() {

		sid = Window.Location.getParameter("sid");
		String sname = Window.Location.getParameter("sname");

		skuListView.getPullToRefreshView().initMeScroll(this, "1.2rem", "0rem");
		skuListView.setPageHeaderText(StringUtils.isEmpty(sname) ? "商品列表" : sname);

	}

}
